package com.pms.mapper;

import com.github.pagehelper.Page;
import com.pms.dto.ParkingPageQueryDTO;
import com.pms.entity.Parking;
import com.pms.vo.ParkingPageQueryVO;
import org.apache.ibatis.annotations.*;

@Mapper
public interface ParkingMapper {

    /**
     * 新增停车位
     * @param parking
     */
    @Insert("insert into parking(community_id, number, status_id, owner_id, update_time)" +
            "values (#{communityId},#{number},#{statusId},#{ownerId},#{updateTime})")
    void save(Parking parking);

    /**
     * 根据停车位编号查询
     * @param number
     * @return
     */
    @Select("select * from parking where number=#{number}")
    Parking getByNumber(String number);

    /**
     * 停车位分页查询
     * @param parkingPageQueryDTO
     * @return
     */
    Page<ParkingPageQueryVO> page(ParkingPageQueryDTO parkingPageQueryDTO);

    /**
     * 根据id批量删除
     * @param id
     */
    @Delete("delete from parking where id=#{id}")
    void delete(Integer id);

    /**
     * 修改停车位信息
     * @param parking
     */
    @Update("update parking set status_id=#{statusId}, owner_id=#{ownerId}, update_time=#{updateTime} where id=#{id}")
    void update(Parking parking);

    /**
     * 统计总数
     * @return
     */
    @Select("select count(*) from parking")
    Integer count();
}
